/**
 * MsgBox - jQuery Plugin
 * version: 1.0 (07/10/2012)
 * @requires jQuery v1.7.2 or later
 *
 * Examples at http://tony.github.com/msgbox
 * License: http://www.apache.org/licenses/LICENSE-2.0
 *
 * Copyright 2012 tony (me@tony.me)
 */
(function($){

	$.msgbox = function (options) {

		// 将options和默认的参数合并
		options = $.extend( {}, $.msgbox.options, options );

		var html = '<div class="tony_msgbox_layer_wrap" id="tony_msgbox" style="display:none">'+
			'<span class="tony_msgbox_layer">'+
				'<span class="tony_ico_'+options.type+'"></span>'+
				options.msg+
				'<span class="tony_end"></span>'+
			'</span>'+
		'</div>';

		// 判断提示框是否在页面中存在，如果存在则干掉
		if($('#tony_msgbox')) {
			$('#tony_msgbox').remove();
		}

		// 提示框插入到页面
		$('body').append(html);
		$('#tony_msgbox').fadeIn('normal').delay(options.delay).fadeOut('slow',function(){
			if(options.end){
	        	options.end();
	        }
		});

        // 跳转到指定url
        if(options.url) {
            window.location.href = options.url;
        }

	};

	/* 默认参数 */
	$.msgbox.options = {
		type: 'success',
		msg: '提交成功',
        url: null,
		delay: 200,
		end:null
	};

})(jQuery);
